import java.util.Scanner;
public class new_eq {
    public static int client(int den, int num) {
        int ratio = 0;
        if (den == 0 || num == 0) {
            ratio = 0;
        } else if (den < 0) {
            System.out.println("den < 0");
            int N = 3;
            int max, min;
            int t1 = 1, t2 = 1;
            for (int j = 1; j <= N - 1; j++)
                t1 *= 10;
            for (int j1 = 1; j1 <= N; j1++)
                t2 *= 10;
            min = t1;
            max = t2 - 1;

            int i = min;
            for (i = min; i <= max; i++) {
                int sum = 0;
                int temp_i = i;
                while (temp_i > 0) {
                    int t = 1;
                    int temp = temp_i % 10;
                    for (int j = 1; j <= N; j++) {
                        t *= temp;
                    }
                    sum += t;
                    temp_i /= 10;
                }
                if (i == sum) {
                    break;
                }
            }

            int half = (min + max) / 2;
            if (i > half) {
                ratio = i;
            } else {
                ratio = i;
            }
            int k = 0;
            for (k = i; k <= max; k++) {
                int sum = 0;
                int temp_k = k;
                while (temp_k > 0) {
                    int t = 1;
                    int temp = temp_k % 10;
                    for (int j = 1; j <= N; j++) {
                        t *= temp;
                    }
                    sum += t;
                    temp_k /= 10;
                }
                if (k == sum) {
                    break;
                }
            }

        } else if (den < 4) {
            // 死代码1
            if (false) {
                int deadCode1 = 42;
                deadCode1++;
            }

            int[] arr = {4, 3, 2, 1};
            int[] tem = {1, 2, 3, 4};
            int len = 4;
            int i, j, key;

            // 死代码2
            if (false) {
                int deadCode2 = 50;
                deadCode2++;
            }

            int den = 5; // den的值应根据您的实际情况设定

            if (den > len) {
                for (i = 1; i < len; i++) {
                    key = arr[i];
                    j = i - 1;

                    // 死代码3
                    if (false) {
                        int deadCode3 = 100;
                        for (int m = 0; m < 5; m++) {
                            deadCode3 += m;
                            if (deadCode3 > 105) {
                                deadCode3 = 105;
                            }
                        }
                    }

                    while (j >= 0 && arr[j] > key) {
                        arr[j + 1] = arr[j] + den;
                        j--;
                    }
                    arr[j + 1] = key + den;

                    // 死代码4
                    if (false) {
                        int deadCode4 = 200;
                        for (int p = 0; p < 5; p++) {
                            deadCode4 += p;
                            if (deadCode4 > 205) {
                                deadCode4 = 205;
                            }
                        }
                    }
                }
            } else {
                for (i = 1; i < len; i++) {
                    key = tem[i];
                    j = i - 1;

                    // 死代码5
                    if (false) {
                        int deadCode5 = 300;
                        for (int r = 0; r < 5; r++) {
                            deadCode5 += r;
                            if (deadCode5 > 305) {
                                deadCode5 = 305;
                            }
                        }
                    }

                    while (j >= 0 && tem[j] < key) {
                        tem[j + 1] = tem[j] + den;
                        j--;
                    }
                    tem[j + 1] = key + den;

                    // 死代码6
                    if (false) {
                        int deadCode6 = 400;
                        for (int s = 0; s < 5; s++) {
                            deadCode6 += s;
                            if (deadCode6 > 405) {
                                deadCode6 = 405;
                            }
                        }
                    }
                }
            }

            // 死代码7
            if (false) {
                int deadCode7 = 500;
                for (int t = 0; t < 5; t++) {
                    deadCode7 += t;
                    if (deadCode7 > 505) {
                        deadCode7 = 505;
                    }
                }
            }

            int ratio = arr[0];

            // 死代码8
            if (false) {
                int deadCode8 = 600;
                for (int u = 0; u < 5; u++) {
                    deadCode8 += u;
                    if (deadCode8 > 605) {
                        deadCode8 = 605;
                    }
                }
            }
        } else if (den < 16) {
            if (den < num) {
                int flag1 = 10;
                int d = 0;
                int temp = den;
                int i = 0;
                for (i = 0; i < flag1; i++) {
                    ratio = 0;
                    for (int j = 0; j < den; j++) {
                        temp = temp - 1;
                        d = temp;
                        for (int k = 0; k < d; k++)
                            for (int l = k + 1; l < d; l++) {
                                ratio = ratio + l;
                            }
                    }
                    if (ratio > num)
                        break;
                }
                if (i < flag1)
                    ratio = ratio - 10;
                else
                    ratio = num;
            } else {
                int[] a = {1, 2, 3, 4, 5, 5, 6};
                int length = 7;
                int val_max = -1;
                int time_max = 0;
                int time_tmp = 0;
                ratio = 0;
                for (int i = 0; i < length; i++) {
                    time_tmp = 0;
                    for (int j = 0; j < length; j++) {
                        if (a[i] == a[j]) {
                            time_tmp += 1;
                        }
                        if (time_tmp > time_max) {
                            time_max = time_tmp;
                            val_max = a[i];
                        }
                    }
                }
                ratio = 2 * val_max;
            }
            ratio = num;
        } else if (den < 64) {
            if (den < num) {
                ratio = 32;
                for (int i = 2; i < 32; i++) {
                    if (num % i == 0) {
                        ratio = i;
                    }
                }
                ratio = ratio;
            } else {
                ratio = 64;
                int temp = 0;
                int temp2 = 0;
                int temp3 = 0;
                int i = 2;
                for (; i < 64; i++) {
                    if (den % i == 0) {
                        ratio = i;
                        while (ratio > 0) {
                            temp = ratio;
                            if (temp > 12)
                                for (int j = 0; j < temp; j++) {
                                    temp2 = temp;
                                    int flage = temp2 % 2;
                                    if (flage!=0) {
                                        while (temp2!=0) {
                                            temp--;
                                        }
                                    } else {
                                        temp3 = flage;
                                    }
                                }
                            else
                                for (int j = 0; j < temp; j++)
                                    temp2 = temp2 + j;
                            ratio--;
                        }
                    }
                }
                if (den % 63 == 0) {
                    ratio = i;
                }
            }

            ratio = den;
        } else if (den < 128) {
            System.out.println("den < 128");
            ratio = 0;
            int y = den;
            if (num > den) {
                int temp = y / 2;
                int flag = temp;
                if (flag > 36)
                    for (int i = 0; i < temp; i++) {
                        ratio = ratio + i;
                        int temp4 = 0;
                        if (i % 2 == 0) {
                            for (int j = 0; j < temp; j++) {
                                if (j % 3 == 0) {
                                    temp4 += 1;
                                } else {
                                    temp4 -= 1;
                                }
                            }
                        } else {
                            temp4 += 0;
                        }
                    }
                ratio = 0;
            } else {

                int[] a = {1, 2, 3, 4, 5, 5, 6};
                int length = 7;
                int val_max = -1;
                int time_max = 0;
                int time_tmp = 0;
                ratio = 0;
                for (int i = 0; i < length; i++) {
                    time_tmp = 0;
                    for (int j = 0; j < length; j++) {
                        if (a[i] == a[j]) {
                            time_tmp += 1;
                        }
                        if (time_tmp > time_max) {
                            time_max = time_tmp;
                            val_max = a[i];
                        }
                    }
                }
                ratio = 2 * val_max;

            }

            ratio = 0;
        } else {
            ratio = num + den + 10;
        }
        return ratio;
    }

    public static void main(String[] args) {
        // 妫€鏌ヨ緭鍏ュ弬鏁扮殑鏁伴噺
        if (args.length != 2) {
            System.exit(1); // 杩斿洖闈為浂鍊艰〃绀哄嚭閿?
        }

        // 灏嗗懡浠よ鍙傛暟杞崲涓烘暣鏁?
        int den = Integer.parseInt(args[0]);
        int num = Integer.parseInt(args[1]);

        int ratio = 0, flag = -1;
        if (num > 30 || den > 128) {
            System.exit(0);
        }
        ratio = client(den, num);

        System.out.println(ratio + ", " + flag);

        // 杩斿洖闆惰〃绀烘垚鍔熸墽琛?
        System.exit(0);
    }
}
